package com.msw.test.controller;

import com.msw.test.model.User;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
public class UserController {

    @GetMapping(value = "/user", produces = {"application/json"})
    @ResponseBody
    public User getUser() {
        log.info("receive getUser request --------------------->");
        User user = new User();
        user.setId(123);
        user.setName("hello,world");
        return user;
    }

    @PostMapping(value = "/user", consumes = {"application/json"}, produces = {"application/json"})
    @ResponseBody
    public User updateUser(@RequestBody User user) {
        log.info("receive updateuUser request +++++++++++++++++++++++++++++>");
        user.setId(user.getId() + 100);
        user.setName(user.getName() + "-xxxxxxx");
        return user;
    }

    @GetMapping("/greeting")
    public String greeting() {
        log.info("receive greeting request ================================>");
        return "greeting";
    }

}
